package com.byxy.ssm.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.byxy.ssm.pojo.Reply;

public interface ReplyMapper {
	@Delete("delete from reply where reply_id=#{replyId}")
    int delete(Integer replyId);
	@Insert("insert into reply(user_id,tip_id,reply_content,reply_publishTime,reply_modifyTime,reply_status) values(#{userId},#{tipId},#{replyContent},#{replyPublishtime},#{replyModifytime},#{replyStatus})")
    int insert(Reply reply);

    @Select("select * from reply where reply_id=#{replyId}")
    @Results(id="dataset",value={
    	@Result(id=true,column="reply_id",property="replyId"),
    	@Result(column="user_id",property="userId"),
    	@Result(column="tip_id",property="tipId"),
    	@Result(column="reply_content",property="replyContent"),
    	@Result(column="reply_publishTime",property="replyPublishtime"),
    	@Result(column="reply_modifyTime",property="replyModifytime"),
    	@Result(column="reply_status",property="replyStatus"),
    })
    Reply getById(Integer replyId);
    
    
    
    @ResultMap("dataset")
    @Select("select * from reply where tip_id=#{tipId}")
    List<Reply> getByTipId(@Param("tipId") Integer tipId);
    
    
    
    @ResultMap("dataset")
    @Select("select * from reply")
    List<Reply> findAll();
    
    

    @Update("update reply set reply_content=#{replyContent},reply_modifyTime=#{replyModifytime},reply_status=#{replyStatus}")
    int update(Reply reply);
}